sentence is truncated - and missing part of the line, including the checksum.
*/
+struct NmeaWaypoint : Waypoint
+{
+ bool added{false};
+};
+
typedef enum {
gp_unknown = 0,
gpgga,
static short_handle mkshort_handle;
static preferred_posn_type posn_type;
static struct tm tm;
-static Waypoint* curr_waypt;
-static Waypoint* last_waypt;
+static NmeaWaypoint* curr_waypt;
+static NmeaWaypoint* last_waypt;
static void* gbser_handle;
static QString posn_fname;
-static QList<Waypoint*> pcmpt_head;
+static QList<NmeaWaypoint*> pcmpt_head;
static int without_date; /* number of created trackpoints without a valid date */
static struct tm opt_tm; /* converted "date" parameter */
}
static void
-nmea_add_wpt(Waypoint* wpt, route_head* trk)
+nmea_add_base_wpt(Waypoint* wpt, route_head* trk)
{
if (datum != DATUM_WGS84) {
double lat, lon, alt;
}
static void
-nmea_release_wpt(Waypoint* wpt)
+nmea_add_wpt(NmeaWaypoint* wpt, route_head* trk)
+{
+ wpt->added = true;
+ nmea_add_base_wpt(wpt, trk);
+}
+
+static void
+nmea_release_wpt(NmeaWaypoint* wpt)
{
- if (wpt && ((wpt->Q.next == nullptr) || (wpt->Q.next == &wpt->Q))) {
+ if (wpt && !wpt->added) {
/* This waypoint isn't queued.
Release it, because we don't have any reference to this
waypoint (! memory leak !) */
if (getposn) {
posn_status st;
nmea_rd_posn_init(fname);
- Waypoint* wpt = nmea_rd_posn(&st);
+ auto wpt = nmea_rd_posn(&st);
if (!wpt) {
return;
}
wpt->shortname = "Position";
- nmea_add_wpt(wpt, nullptr);
+ nmea_add_base_wpt(wpt, nullptr);
return;
}
hms = hms / 100;
tm.tm_hour = hms % 100;
- Waypoint* waypt = new Waypoint;
+ auto waypt = new NmeaWaypoint;
nmea_set_waypoint_time(waypt, &tm, fsec);
hms = hms / 100;
tm.tm_hour = (long) hms % 100;
- Waypoint* waypt = new Waypoint;
+ auto waypt = new NmeaWaypoint;
nmea_set_waypoint_time(waypt, &tm, fsec);
return;
}
- Waypoint* waypt = new Waypoint;
+ auto waypt = new NmeaWaypoint;
WAYPT_SET(waypt, speed, KNOTS_TO_MPS(speed));
WAYPT_SET(waypt, course, course);
lngdeg = -lngdeg;
}
- Waypoint* waypt = new Waypoint;
+ auto waypt = new NmeaWaypoint;
waypt->latitude = ddmm2degrees(latdeg);
waypt->longitude = ddmm2degrees(lngdeg);
waypt->shortname = sname;
}
if (lat || lon) {
- curr_waypt = new Waypoint;
+ curr_waypt = new NmeaWaypoint;
curr_waypt->longitude = pcmpt_deg(lon);
curr_waypt->latitude = pcmpt_deg(lat);
route_head* trk_head = route_head_alloc();
track_add_head(trk_head);
while (!pcmpt_head.isEmpty()) {
- Waypoint* wpt = pcmpt_head.takeFirst();
+ auto wpt = pcmpt_head.takeFirst();
nmea_add_wpt(wpt, trk_head);
}
}
nmea_parse_one_line(ibuf);
if (lt != last_read_time) {
if (last_read_time) {
- Waypoint* w = curr_waypt;
+ auto w = curr_waypt;
lt = last_read_time;
curr_waypt = nullptr;